#include "IMIControlSwitch.h"
IMIControlSwitch* IMIControlSwitch::create(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite)
{
    IMIControlSwitch* pRet = new IMIControlSwitch();
    if (pRet && pRet->initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, NULL, NULL))
    {
		pRet->setTouchPriority(-129);
		pRet->setTouchMode(kCCTouchesOneByOne);
		pRet->setTouchEnabled(true);
        pRet->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pRet);
    }
    return pRet;
}

IMIControlSwitch* IMIControlSwitch::create(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel)
{
    IMIControlSwitch* pRet = new IMIControlSwitch();
    if (pRet && pRet->initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel))
    {
		pRet->setTouchPriority(-129);
		pRet->setTouchMode(kCCTouchesOneByOne);
		pRet->setTouchEnabled(true);
        pRet->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pRet);
    }
    return pRet;
}

void IMIControlSwitch::registerWithTouchDispatcher()
{
    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, -128, true);
}